package com.example.fraud;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public record FraudReviewService(
        FraudCheckHistoryRepository fraudCheckHistoryRepository) {
    public Boolean isFraudulentCustomer(String customerEmail) {
        // 查询该email是否有不诚信历史记录
        List<FraudCheckHistory> histories = fraudCheckHistoryRepository
                .findAllByEmailAndIsFraudster(customerEmail, true);
        log.info("Fraud check customer with Email: {}, has {} record.", customerEmail, histories.size());
        // 又返回记录表示有不诚信记录
        if (histories!=null && histories.size()>0) {
            return true;
        } else {
            return false;
        }
    }
}